﻿using Abp.Dependency;
using Abp.Domain.Services;
using GN.Pay.Core.Entities;
using GN.Pay.Core.Runtime.Caching;
using GN.Pay.Core.Values.Channel;
using GN.Pay.Core.Values.Entities;
using GN.Pay.TradeChannel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Services
{
    /// <summary>
    /// 交易缓存服务
    /// </summary>
    public interface ITradeCacheService : ISingletonDependency
    {
        /// <summary>
        /// 获取通道集合
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <returns></returns>
        List<ITradeChannel> GetTradeChannels(string appId);

        /// <summary>
        /// 移除通道集合
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <returns></returns>
        void RemoveTradeChannels(string appId);

        /// <summary>
        /// 获取交易通道
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <param name="channelId">通道id</param>
        /// <returns></returns>
        ITradeChannel GetTradeChannel(string appId, string channelId);

        /// <summary>
        /// 移除交易通道
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <param name="channelId">通道id</param>
        void RemoveTradeChannel(string appId, string channelId);

        /// <summary>
        /// 获取商户
        /// </summary>
        /// <param name="merchantId">商户Id</param>
        /// <returns></returns>
        MerchantInfo GetMerchantInfo(string merchantId);

        /// <summary>
        /// 移除商户
        /// </summary>
        /// <param name="merchantId">商户Id</param>
        /// <returns></returns>
        void RemoveMerchantInfo(string merchantId);

        /// <summary>
        /// 获取商户应用
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <returns></returns>
        MerchantAppCahceInfo GetMerchantAppInfo(string appId);

        /// <summary>
        /// 移除商户应用
        /// </summary>
        /// <param name="appId">应用Id</param>
        /// <returns></returns>
        void RemoveMerchantAppInfo(string appId);

        /// <summary>
        /// 设置付款返回通知
        /// </summary>
        /// <param name="notify">通知</param>
        void SetPayReturnNotify(TradeNotify notify);

        /// <summary>
        /// 异步设置付款返回通知
        /// </summary>
        /// <param name="notify">通知</param>
        Task SetPayReturnNotifyAsync(TradeNotify notify);

        /// <summary>
        /// 获取付款返回通知
        /// </summary>
        /// <param name="tradeNo">交易号</param>
        /// <returns></returns>
        TradeNotify GetPayReturnNotify(string tradeNo);

        /// <summary>
        /// 异步获取付款返回通知
        /// </summary>
        /// <param name="tradeNo">交易号</param>
        /// <returns></returns>
        Task<TradeNotify> GetPayReturnNotifyAsync(string tradeNo);

        /// <summary>
        /// 获取商户会员申请票据
        /// </summary>
        /// <param name="token">票据</param>
        /// <returns></returns>
        MerchantMemberBankCardBindApplyToken GetMerchantMemberBankCardBindToken(string token);

        /// <summary>
        /// 设置商户会员申请票据
        /// </summary>
        /// <param name="token">票据</param>
        /// <param name="applyToken">申请</param>
        void SetMerchantMemberBankCardBindToken(string token, MerchantMemberBankCardBindApplyToken applyToken);

        /// <summary>
        /// 移除绑定
        /// </summary>
        /// <param name="token">票据</param>
        void RemoveMerchantMemberBankCardBindToken(string token);

        /// <summary>
        /// 获取协议支付短信
        /// </summary>
        /// <param name="payId">付款Id</param>
        ProtocolPaySmsCheck GetProtocolPaySmsCheck(string payId);

        /// <summary>
        /// 移除协议支付
        /// </summary>
        /// <param name="payId"></param>
        void RemoveProtocolPaySmsCheck(string payId);

        /// <summary>
        /// 设置协议支付短信
        /// </summary>
        /// <param name="payId">付款Id</param>
        /// <param name="protocolPaySmsCheck">协议</param>
        void SetProtocolPaySmsCheck(string payId, ProtocolPaySmsCheck protocolPaySmsCheck);

        /// <summary>
        /// 获取短信验证码
        /// </summary>
        /// <param name="checkCodeType">验证码类型</param>
        /// <param name="key">值</param>
        /// <returns></returns>
        string GetSmsCheckCode(SmsCheckCodeType checkCodeType, string key);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="checkCodeType"></param>
        /// <param name="key"></param>
        /// <param name="checkCodeHash"></param>
        void SetSmsCheckCode(SmsCheckCodeType checkCodeType, string key, string checkCodeHash);

        /// <summary>
        /// 设置付款通知
        /// </summary>
        /// <param name="uniqueNo">>唯一号，交易号</param>
        void SetPayNotify(string uniqueNo);

        /// <summary>
        /// 是否支付通知
        /// </summary>
        /// <param name="uniqueNo">唯一号，交易号</param>
        /// <returns></returns>
        bool IsPayNotify(string uniqueNo);
    }
}
